package com.matt.order.controller;

import cn.hutool.crypto.Mode;
import com.matt.order.dto.PlayWithDto;
import com.matt.order.service.PlayWithEnterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/playWithEnter")
public class PlayWithEnterController {

    @Autowired
    PlayWithEnterService playWithEnterService;


    /**
     * 初期化
     * @param model
     * @return
     */
    @RequestMapping("/init")
    public String playWithEnterInit(Model model) {

        return "order/playWith-enter";
    }

    /**
     * 陪玩信息录入
     * @param model
     * @return
     */
    @RequestMapping("/insertPlayInfo")
    @ResponseBody
    public Map<String, Object> playWithInfoInsert(Model model, PlayWithDto playWithDto) {
        Map<String, Object> res = new HashMap<>();

        int result = playWithEnterService.playWithInfoInsert(playWithDto);
        if (result != 0) {
            res.put("code", 201);
        } else {
            res.put("code", 200);
        }
        return res;
    }
}
